package com.shengsiyuan.nio;

import java.io.FileInputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/**
 * Created by deng_wb on 2019/8/15
 */
public class NioTest2 {
    public static void main(String[] args)throws Exception {
        FileInputStream fileInputStream = new FileInputStream("NioTest2.txt");
        FileChannel channel = fileInputStream.getChannel();
        ByteBuffer byteBuffer = ByteBuffer.allocate(512);
        channel.read(byteBuffer);
        byteBuffer.flip();

        while (byteBuffer.remaining()>0){
            byte b = byteBuffer.get();
            System.out.println("Character: "+(char)b);
        }

        fileInputStream.close();
    }
}
